<template>
  <div id="test">
    <textarea id="mytextarea" :style="[{width:width,height: height}]"></textarea>
  </div>
</template>

<script>
  // import { mapState, mapMutations, mapActions } from 'vuex'
  // import validMixins from '@/mixins/validMixins.js'
  import plugins from './plugins'
  import toolbar from './toolbar'

  export default {
    name: 'test',
    components: {
      // TablesGZCJ,
    },
    // mixins: [validMixins],
    props: {
      width: {
        default: '100%'
      },
      height: {
        default: '400px'
      },
    },
    // mixins: [validMixins],
    data() {
      return {
        levelList: null,
        tinymceExample: null
      }
    },
    computed: {
      // ...mapState('user', ['token', 'userInfo'])
    },
    watch: {
      // 'cmAddForm.enginePlatform': function(val) {
      //   console.log('enginePlatformval', val)
      //   if (val) {
      //     this.emissionOptionReq()
      //   }
      // }
    },
    created() {

    },
    mounted() {
      this.initTinymce();
    },
    destroyed() {

    },
    methods: {
      initTinymce() {
        if (tinymce && tinymce.get("mytextarea")) {
          this.destroyTinymce();
        }
        let that = this
        tinymce.init({
          selector: '#mytextarea',
          readonly: true,
          language: 'zh_CN', //调用放在langs文件夹内的语言包
          // toolbar: false, //隐藏工具栏
          // menubar: false, //隐藏菜单栏
          // inline: true, //开启内联模式
          toolbar: false,
          plugins: false,
          // //选中时出现的快捷工具，与插件有依赖关系
          // images_upload_handler(blobInfo, success, failure, progress) {
          //   console.log('图片上传images_upload_handler')
          //   that.uploadImage(blobInfo, success, failure, progress)
          // },
        });
      },
      uploadImage(blobInfo, success, failure, progress) {
        let formData = new FormData();
        formData.append('file', blobInfo.blob())
        this.$axiosReq({
          url: 'rxd-service-fm/fm/upload',
          data: formData, method: 'POST', bfLoading: true, isUploadFile: true
        }).then(res => {
          //获取图片的地址
          success(res.data.fullPath);
          progress(100)
        })
      },
      getValue() {
        return tinymce.get("mytextarea").getContent()
      },
      setValue(value) {
        tinymce.get("mytextarea").setContent(value)
      },
      destroyTinymce() {
        tinymce.get("mytextarea").destroy()
      }
      // ...mapActions('user', ['closeSideBar']),
      // ...mapMutations('user', ['CHAGE_TOKEN']),
    }
  }
</script>

<style lang="scss">
  #mceu_2-body {
    display: none !important;
  }
  .mce-flow-layout {
    display: none !important;
  }
  .mce-tinymce{
    margin-top: -4px!important;
    box-shadow:none!important;
  }


</style>

